<?php
class DatabaseLogger {
    
    static $Log;

    function __construct() {
        App::import('Model', 'Log');
        if(!isset($this->Log)){
            $this->Log = new Log;    
        }        
    }
 
    function write($type, $message) {
        $log['type'] = ucfirst($type);
        $log['time'] = date('Y-m-d H:i:s');
        if(is_array($message))
        {
            $log['message']     = $message['message'];
            $log['parser_name'] = $message['parser_name'];
            $log['url']         = $message['url'];            
        }
        else
        {
            $log['message'] = $message;    
        }
        
        $this->Log->create();
        return $this->Log->save($log);
    }
 
}
?>